return 0;
}
-void pcap_block_write_file(FILE *f)
+bool pcap_block_write_file(FILE *f)
{
- fwrite(pcap_buf, pcap_hdr->len, 1, f);
+ if (fwrite(pcap_buf, pcap_hdr->len, 1, f) != 1)
+ return false;
+
fflush(f);
+ return true;
}
void *pcap_block_get(size_t *len)
size_t n = ucv_type(arg) == UC_ARRAY ? ucv_array_length(arg) : 1;
struct udebug_snapshot **s;
struct udebug_iter it;
+ bool ret = false;
if (!p)
return NULL;
if (ucv_type(arg) == UC_ARRAY)
for (size_t i = 0; i < n; i++) {
if ((s[i] = uc_get_snapshot(ucv_array_get(arg, i))) == NULL)
- return NULL;
+ goto out;
} else {
if ((s[0] = uc_get_snapshot(arg)) == NULL)
- return NULL;
+ goto out;
}
udebug_iter_start(&it, s, n);
if (pcap_interface_rbuf_init(&p->pcap, rb))
continue;
- pcap_block_write_file(p->f);
+ if (!pcap_block_write_file(p->f))
+ return NULL;
}
if (pcap_snapshot_packet_init(&u, &it))
continue;
- pcap_block_write_file(p->f);
+ if (!pcap_block_write_file(p->f))
+ return NULL;
+
+ ret = true;
}
- return NULL;
+out:
+ return ucv_boolean_new(ret);
}
static void
int pcap_interface_rbuf_init(struct pcap_context *p, struct udebug_remote_buf *rb);
int pcap_snapshot_packet_init(struct udebug *ctx, struct udebug_iter *it);
-void pcap_block_write_file(FILE *f);
+bool pcap_block_write_file(FILE *f);
void *pcap_block_get(size_t *len);
#endif